package com.carrent.demo.Controller;

import com.carrent.demo.Domain.ComplicatedInformation;
import com.carrent.demo.Domain.Contract;
import com.carrent.demo.Service.ComplicatedInformationService;
import com.carrent.demo.Utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/complicated")
public class ComplicatedInformationController {
    @Autowired
    ComplicatedInformationService complicatedInformationService;

    @GetMapping("/page")
    public R getPage(Integer page, Integer pageSize, String number, @DateTimeFormat String beginTime, @DateTimeFormat String endTime){
        final List<ComplicatedInformation> page1 = complicatedInformationService.getPage((page - 1) * pageSize, pageSize, number,beginTime,endTime);
        final Integer count = complicatedInformationService.getCount(number, beginTime, endTime);
        return  R.success(page1,count);
    }
    @PutMapping
    public  R editContract(@RequestBody ComplicatedInformation complicatedInformation) throws ParseException {
        complicatedInformationService.editContract(complicatedInformation);
        return  R.success(1);
    }


}